package com.joey.cart.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author: Joey
 * @Description:
 * @date:2024/7/6 17:15
 */
@Component
@Slf4j
public class CartListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "cart.queue", durable = "true"),
            exchange = @Exchange(name = "cart.topic"),
            key = "cart.success"
    ))
    public void listenPaySuccess(String msg, MessageProperties mp){
        log.info("cart-server接收到数据=> {},消息ID = {}",msg,mp.getMessageId());
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "testQueue.q2"),
            exchange = @Exchange(name = "cart.topic")
    ))
    public void listenPaySuccess2(String msg){
        log.info("cart-server接收到数据=> {}",msg);
    }

}
